/**获取时间*/
export default {
	formatDateTime(dateTimeString) { //接受参数,进行转换
		let dateObj = new Date(dateTimeString);
		let localTime = new Date(dateObj.getTime() + (dateObj.getTimezoneOffset() * 60000) + (8 * 60 * 60 * 1000));
		let year = localTime.getFullYear();
		let month = ('0' + (localTime.getMonth() + 1)).slice(-2);
		let day = ('0' + localTime.getDate()).slice(-2);
		let hours = ('0' + localTime.getHours()).slice(-2);
		let minutes = ('0' + localTime.getMinutes()).slice(-2);
		let seconds = ('0' + localTime.getSeconds()).slice(-2); // 获取秒数
		return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
	},
	onlyNumOnePoint(number_only) {
		console.log('number_only',number_only)
		//先把非数字的都替换掉，除了数字和小数点
		number_only = number_only.replace(/[^\d.]/g, "");
		//必须保证第一个为数字而不是小数点
		number_only = number_only.replace(/^\./g, "");
		//保证只有出现一个小数点而没有多个小数点
		number_only = number_only.replace(/\.{2,}/g, ".");
		//保证小数点只出现一次，而不能出现两次以上
		number_only = number_only.replace(".","$#$").replace(/\./g, "").replace("$#$", ".");
		//保证只能输入两个小数
		// number_only = number_only.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
		return number_only;
	},
}


// export {
// 	formatDateTime
// }
